<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index');
Route::get('/home/test', 'HomeController@test');
Route::resource('student', 'StudentController');
Route::group(['prefix' => 'api'],function ($router)
{
    $router->get('schools', 'ApiController@schools');
    $router->get('location', 'ApiController@location');
});

Route::group(['prefix' => 'common'],function ($router)
{
    $router->post('upload', 'CommonController@upload');
});

Route::group(['prefix' => 'admin','namespace' => 'Admin','middleware' => ['auth']],function ($router)
{
	$router->get('/','DashboardController@index');
	$router->get('/dash','DashboardController@index')->name('system.index');
	$router->get('/i18n', 'DashboardController@dataTableI18n');
	// 权限
	require(__DIR__ . '/admin/permission.php');
	// 角色
	require(__DIR__ . '/admin/role.php');
	// 用户
	require(__DIR__ . '/admin/user.php');
	// 菜单
	require(__DIR__ . '/admin/menu.php');

    //电子门票
    require(__DIR__ . '/admin/eticket.php');

    //报名
    require(__DIR__ . '/admin/apply.php');
});

// 后台系统日志
Route::group(['prefix' => 'admin/log','middleware' => ['auth','check.permission:log']],function ($router)
{
	$router->get('/','\Arcanedev\LogViewer\Http\Controllers\LogViewerController@index')->name('log-viewer::dashboard');
	$router->get('list','\Arcanedev\LogViewer\Http\Controllers\LogViewerController@listLogs')->name('log-viewer::logs.list');
	$router->post('delete','\Arcanedev\LogViewer\Http\Controllers\LogViewerController@delete')->name('log-viewer::logs.delete');
	$router->get('/{date}','\Arcanedev\LogViewer\Http\Controllers\LogViewerController@show')->name('log-viewer::logs.show');
	$router->get('/{date}/download','\Arcanedev\LogViewer\Http\Controllers\LogViewerController@download')->name('log-viewer::logs.download');
	$router->get('/{date}/{level}','\Arcanedev\LogViewer\Http\Controllers\LogViewerController@showByLevel')->name('log-viewer::logs.filter');

});

Route::group(['prefix' => 'wechat'],function ($router)
{
    $router->any('/test', 'WechatController@test');
    $router->get('/headimgurl', 'WechatController@headimgurl');
    $router->any('/login', 'WechatController@login');
    $router->any('/auth', 'WechatController@auth');
    $router->get('/bind', 'WechatController@bind');
    $router->get('/user/{openid}', 'WechatController@user');
    $router->any('/callback/{appid}', 'WechatController@callback');
});

//电子门票
Route::group(['prefix' => 'eticket','middleware' => ['student']],function ($router)
{
    $router->get('/', 'EticketController@index');
    $router->get('/ajaxIndex', 'EticketController@ajaxIndex');
    $router->get('/history', 'EticketController@history');
    $router->get('/ajaxHistory', 'EticketController@ajaxHistory');
    $router->get('/activities', 'EticketController@activities');
    $router->get('/ajaxActivities', 'EticketController@ajaxActivities');
    $router->get('/activity/{id}', 'EticketController@activity');
    $router->get('/ajaxActivity/{id}', 'EticketController@ajaxActivity');
    $router->get('/join/{id}', 'EticketController@join');
    $router->get('/transfer/{id}', 'EticketController@transfer');
    $router->get('/qrcodeUrl/{id}', 'EticketController@qrcodeUrl');
    $router->get('/writeOff/{token}', 'EticketController@writeOff');
    $router->get('/offlineGetTicket/{aid}/{way}/{type}', 'EticketController@offlineGetTicket');
});
Route::group(['prefix' => 'user', 'namespace' => 'Auth','middleware' => ['auth']],function ($router)
{
    $router->get('/', 'UserController@index');
    $router->get('/edit', 'UserController@edit');
    $router->put('/update', 'UserController@update');
});


//报名
Route::group(['prefix' => 'apply'],function ($router)
{
    $router->get('/', 'ApplyController@index');
    $router->post('/store', 'ApplyController@store');
});
Route::resource('apply', 'ApplyController');


Route::group(['prefix' => 'act'],function ($router)
{
    $router->get('/home', 'ActController@home');
});